package com.leiy.job.controller;

import com.alibaba.fastjson.JSON;
import com.leiy.job.Pojo.JobInfo;
import com.leiy.job.resultjson.ResultObject;
import com.leiy.job.service.JobInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@CrossOrigin(origins = "*",allowedHeaders = "*",methods = {},allowCredentials = "true")
public class JobInfoController {

    @Autowired
    private JobInfoService jobInfoService;

    @RequestMapping(path="/hello")
    @ResponseBody
    public String sayShow(){
        System.out.println("hello spring mvc");
        return  "success";
    }

    @RequestMapping(path="/jobinfo")
    public String jobInfo(){
        return  "jobinfo";
    }

    @RequestMapping(path="/index")
    public String index(){
        return  "index";
    }

    @RequestMapping(path="/list")
    @ResponseBody
    public String listJobInfo(){
        return JSON.toJSONString(new ResultObject(jobInfoService.findAll(new JobInfo())));
    }

}
